package fairygui.editor.settings
{
   import fairygui.editor.Consts;
   import fairygui.editor.gui.EScrollBarDisplayConst;
   import fairygui.editor.gui.EUIProject;
   import fairygui.editor.utils.UtilsStr;
   
   public class CommonSettings extends ISerializedSettings
   {
       
      
      public var font:String;
      
      public var fontSize:int;
      
      public var textColor:uint;
      
      public var fontAdjustment:Boolean;
      
      public var colorScheme:Array;
      
      public var fontSizeScheme:Array;
      
      public var horizontalScrollBar:String;
      
      public var verticalScrollBar:String;
      
      public var defaultScrollBarDisplay:String;
      
      public var tipsRes:String;
      
      public var buttonClickSound:String;
      
      public function CommonSettings()
      {
         super();
         _fileName = "Common";
         this.colorScheme = [];
         this.fontSizeScheme = [];
      }
      
      override public function load() : void
      {
         var _loc1_:Object = loadFile();
         this.font = _loc1_.font;
         this.fontSize = _loc1_.fontSize;
         this.textColor = UtilsStr.convertFromHtmlColor(_loc1_.textColor);
         if(_loc1_.fontAdjustment != undefined && (_project.type == EUIProject.TYPE_EGRET || _project.type == EUIProject.TYPE_LAYABOX))
         {
            this.fontAdjustment = _loc1_.fontAdjustment;
         }
         else
         {
            this.fontAdjustment = true;
         }
         if(!this.font)
         {
            this.font = "_sans";
         }
         if(this.fontSize == 0)
         {
            this.fontSize = 12;
         }
         this.colorScheme = _loc1_.colorScheme;
         if(!this.colorScheme)
         {
            this.colorScheme = [Consts.g.text118 + " #FF0000"];
         }
         this.fontSizeScheme = _loc1_.fontSizeScheme;
         if(!this.fontSizeScheme)
         {
            this.fontSizeScheme = [Consts.g.text119 + " 30"];
         }
         var _loc2_:Object = _loc1_.scrollBars;
         if(_loc2_)
         {
            this.verticalScrollBar = _loc2_.vertical;
            this.horizontalScrollBar = _loc2_.horizontal;
            this.defaultScrollBarDisplay = _loc2_.defaultDisplay;
            if(!this.defaultScrollBarDisplay)
            {
               this.defaultScrollBarDisplay = EScrollBarDisplayConst.VISIBLE;
            }
         }
         else
         {
            this.defaultScrollBarDisplay = EScrollBarDisplayConst.VISIBLE;
         }
         this.tipsRes = _loc1_.tipsRes;
         this.buttonClickSound = _loc1_.buttonClickSound;
      }
      
      override public function save() : void
      {
         var _loc1_:Object = {};
         _loc1_.font = this.font;
         _loc1_.fontSize = this.fontSize;
         _loc1_.textColor = UtilsStr.convertToHtmlColor(this.textColor);
         if(!this.fontAdjustment && (_project.type == EUIProject.TYPE_EGRET || _project.type == EUIProject.TYPE_LAYABOX))
         {
            _loc1_.fontAdjustment = this.fontAdjustment;
         }
         _loc1_.colorScheme = this.colorScheme;
         _loc1_.fontSizeScheme = this.fontSizeScheme;
         var _loc2_:Object = {};
         _loc1_.scrollBars = _loc2_;
         _loc2_.vertical = this.verticalScrollBar;
         _loc2_.horizontal = this.horizontalScrollBar;
         _loc2_.defaultDisplay = this.defaultScrollBarDisplay;
         _loc1_.tipsRes = this.tipsRes;
         _loc1_.buttonClickSound = this.buttonClickSound;
         saveFile(_loc1_);
         _project.editorWindow.colorPresetMenu.needUpdate = true;
         _project.editorWindow.fontSizePresetMenu.needUpdate = true;
      }
   }
}
